﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace EhotelSystem.BackviewWebpage
{
    public partial class Register : System.Web.UI.Page
    {
        String Addrole;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            MembershipCreateStatus status;


            Membership.CreateUser(txtUerName.Text, txtPassword.Text, txtEmail.Text, "a", "b", true, out(status));

            if (status == MembershipCreateStatus.Success)
            {
                lblMessage.Text = "welcome..." + txtUerName.Text + "member";

                HotelLinqDataContext db = new HotelLinqDataContext();
                User_profile a = new User_profile();
                a.UserID = (Guid)Membership.GetUser(txtUerName.Text).ProviderUserKey;
                a.Firstname = txtFirstName.Text;
                a.Lastname = txtLastName.Text;
                db.User_profiles.InsertOnSubmit(a);
                db.SubmitChanges();
                String role = DropDownList1.SelectedItem.Value.ToString();
                if (role == "Hotel's officer")
                {
                    Addrole = "HotelOfficer";
                }
                if (role == "Administrater")
                {
                    Addrole = "Administrator";

                }
                Roles.AddUserToRole(Membership.GetUser(txtUerName.Text).ToString(), Addrole);
            }
            else
            {
                lblMessage.Text = "problem occur";
            }


        }

        protected void txtPassword_TextChanged(object sender, EventArgs e)
        {

        }

        protected void rbErawam_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
